﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using App.Core.Extensions;
using App.Domain;
using App.Web.ViewModels;
using App.Web.Utility;
using AutoMapper;

namespace App.Web.Areas.Private.Controllers
{
    [Authorize(Roles = "Company Admin,Company User,Site User,Admin")]
    public class AccountController : BaseController
    {
		private AppEntities _Context = new AppEntities();
        
		#region Constructors
		public AccountController()
		{
		}

		public AccountController(UserViewModel currentUser)
			: base(currentUser)
        {
        }
		#endregion Constructors

		#region Action Methods
        public ActionResult Index()
        {
            return RedirectToAction("dashboard");
        }
        public ActionResult DashBoard()
        {
            if (UserInfo.IsAdmin)            
                return View("AdminDashBoard");            
            else if (UserInfo.IsSiteUser)
                return View("SiteUserDashboard", LoggedInUser);            
            else
            {
                EntityRepository repo = new EntityRepository();
                Company company = repo.GetCompanyByID(LoggedInUser.Company.ID);
                CompanyViewModel viewModel = Mapper.Map<CompanyViewModel>(company);
                return View(viewModel);
            }
        }        
		#endregion Action Methods
		
		#region Helper Methods

        #endregion			
    }
}
